package pl.kosmowska.ewelina.client.views.widgets;

import com.google.gwt.core.client.GWT;
import com.google.gwt.event.dom.client.ClickEvent;
import com.google.gwt.event.dom.client.ClickHandler;
import com.google.gwt.uibinder.client.UiBinder;
import com.google.gwt.uibinder.client.UiField;
import com.google.gwt.user.client.ui.Button;
import com.google.gwt.user.client.ui.DialogBox;
import com.google.gwt.user.client.ui.Label;
import com.google.gwt.user.client.ui.Widget;

public class MessageDialogBox extends DialogBox {
    private static final Binder binder = GWT.create(Binder.class);
    interface Binder extends UiBinder<Widget, MessageDialogBox> {
    }

    @UiField
    Label errorLabel;
    @UiField
    Button hideBtn;

    public MessageDialogBox(String errorMessage) {
        setWidget(binder.createAndBindUi(this));
        initDialogBox(errorMessage);
    }

    private void initDialogBox(String errorMessage) {
        errorLabel.setText(errorMessage);
        hideBtn.addClickHandler( new ClickHandler() {
            @Override
            public void onClick(ClickEvent event) {
                hide();
            }
        });
    }
}

